<template>
	<view>
		<view class="indexs">
			<view class="header header_wi" :style="'padding-top: ' + navH + 'px;'">
				<view class="header_height" :style="'height:' + gaodu + 'px;line-height:' + gaodu + 'px;top:' + gaodutops + 'px;'">
					<view class="index_h_cont3">
						<view class="index_wenben_img" @tap="jumpzuo"><image :src="imgUrl + '/dzx_img33.png'" mode="widthFix"></image></view>
						<view class="index_wenben">{{ $t('page_chaxun.inquire') }}</view>
					</view>
				</view>
				<view class="coloe_title">s</view>
			</view>
			<view class="index_center" :style="'padding-top:' + (navH + 50) + 'px;    padding-bottom: 180rpx;'">
				<view class="chaxun_center">
					<view class="chaxun_center_list">
						<!-- <view class="chaxun_center_cont">
          <view class="chaxun_center_cont_l">
            <image src="../../pages/images/dzx_img65.png'"></image>
            <text>查询类型</text>
          </view>
          <view class="chaxun_center_cont_r">
            <text>国内快递查询</text>
            <image src="../../pages/images/dzx_img42.png'"></image>
          </view>
        </view> -->
						<view class="chaxun_center_cont">
							<view class="chaxun_center_cont_l">
								<image :src="imgUrl + '/dzx_img27.png'"></image>
								<text>{{$t('page_baoguoyg.tracking_number')}}</text>
							</view>
							<view class="chaxun_center_cont_r"><input type="text" :placeholder="$t('page_other.请输入快递单号')" :value="kuaididanhao" @input="kuaididanhaoFun" /></view>
						</view>
					</view>
					<view class="chaxun_center_btn">
						<view class="chaxun_center_btns" @tap="chaxuns">{{ $t('page_chaxun.inquireNow') }}</view>
					</view>

					<view class="chaxun_center_chaxun">
						<view class="chaxun_center_chaxun_title">{{ $t('page_chaxun.searchResult') }}</view>
						<view class="chaxun_center_chaxun_list" v-if="arrlist.length != 0">
							<view class="chaxun_center_chaxun_xian" v-if="arrlist.length != 1 && arrlist.length != 0"><view class="chaxun_center_chaxun_xianss"></view></view>
							<view class="chaxun_center_chaxun_cont" v-for="(item, index) in arrlist" :key="index">
								<view class="chaxun_center_chaxun_yuan"><image :src="imgUrl + (index == 0 ? 'dzx_img66.png' : 'dzx_img67.png')"></image></view>

								<view class="chaxun_center_chaxun_txt">
									<view class="chaxun_center_chaxun_t1" :style="index == 0 ? 'color: #4ad5ac;' : ''">{{ item.logistics_describe }}</view>
									<view class="chaxun_center_chaxun_t1" :style="index == 0 ? 'color: #4ad5ac;' : ''">{{ item.created_time }}</view>
								</view>
							</view>
						</view>
					<!-- 	<view class="chaxun_center_chaxun_list" v-if="arrlistforig.length != 0">
							<view class="chaxun_center_chaxun_xian" v-if="arrlistforig.length != 1 && arrlistforig.length != 0">
								<view class="chaxun_center_chaxun_xianss"></view>
							</view>
							<view class="chaxun_center_chaxun_cont" v-for="(item, index) in arrlistforig" :key="index">
								<view class="chaxun_center_chaxun_yuan"><image :src="imgUrl + (index == 0 ? 'dzx_img66.png' : 'dzx_img67.png')"></image></view>

								<view class="chaxun_center_chaxun_txt">
									<view class="chaxun_center_chaxun_t1" :style="index == 0 ? 'color: #4ad5ac;' : ''">【{{ item.status }}】{{ item.context }}</view>
									<view class="chaxun_center_chaxun_t1" :style="index == 0 ? 'color: #4ad5ac;' : ''">{{ item.ftime }}</view>
								</view>
							</view>
						</view>
						<view class="chaxun_center_chaxun_tishi" v-if="arrlistforig.length == 0 && arrlist.length == 0">
							<image :src="imgUrl + '/dzx_img37.png'"></image>
							<text>{{ $t('page_chaxun.noLogisticsInformation') }}</text>
						</view> -->
					</view>
				</view>
			</view>
		</view>

		<!-- parse <template is="menu" :data="...item"></template> -->
		<tabbar :showmenu="menu_type" current="1"></tabbar>
	</view>
</template>

<script>
const app = getApp();

let request = require('../../utils/require');
import tabbar from '@/components/tabbar/tabbar.vue';
export default {
	components: {
		tabbar
	},
	data() {
		return {
			navH: app.globalData.navHeight,
			gaodu: app.globalData.height,
			gaodutops: app.globalData.top,
			imgUrl: app.globalData.imgUrl,
			indexId: 1,
			switchFunlist: '',
			menu_type: uni.getStorageSync('menu_type'),
			item: {
				indexId: 1,
				colors: '#fff;',
				isfujin: '',
				isshop: ''
			},
			banertrue: false,
			tankuangisshows: false,
			kuaididanhao: '',
			arrlist: [],
			// arrlistforig: []
		};
	},
	/**
	 * 生命周期函数--监听页面加载
	 */ onLoad(options) {
		console.log(options, '222');
		var that = this;
		if (options.id) {
			that.kuaididanhao = options.id
			that.chaxunkuaidi(options.id);
		}
	},
	onShow() {
		var that = this;
		that.switchFun();
		uni.setNavigationBarTitle({
		      title: uni.getStorageSync("setting").name
		});
	},
	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady: function() {},
	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide: function() {},
	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload: function() {},
	/**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
	onPullDownRefresh: function() {},
	/**
	 * 页面上拉触底事件的处理函数
	 */
	onReachBottom: function() {},
	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage: function() {
		var thisUserInfo = uni.getStorageSync('userInfo');
		var sett =  uni.getStorageSync('setting');
		var shareObj = {
			title: sett.name,
			desc: sett.desc,
			// 默认是小程序的名称(可以写SOGO express集运等)
			path: '/pages/chaxun/chaxun?scene=uid%3A' + thisUserInfo.user_id,
			// 默认是当前页面，必须是以‘/’开头的完整路径
			imageUrl: '',
			//自定义图片路径，可以是本地文件路径、代码包文件路径或者网络图片路径，支持PNG及JPG，不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
			success: function(res) {
				// 转发成功之后的回调
				if (res.errMsg == 'shareAppMessage:ok') {
				}
			},
			fail: function() {
				// 转发失败之后的回调
				if (res.errMsg == 'shareAppMessage:fail cancel') {
					// 用户取消转发
				} else {
					if (res.errMsg == 'shareAppMessage:fail') {
					}
				}
			}
		};
		return shareObj;
	},
	methods: {
		tiaozhuan(e) {
			uni.navigateTo({
				url: e.currentTarget.dataset.url
			});
		},

		kuaididanhaoFun(e) {
			this.kuaididanhao = e.detail.value
		},

		chaxuns() {
			var that = this;
			if (that.kuaididanhao != '') {
				var data = {
					token: uni.getStorageSync('token'),
					code: that.kuaididanhao
				};
				request.post(`index.php?s=/api/package/logicist&wxapp_id=` + uni.getStorageSync('web_id'), data).then(res => {
					console.log(res.data.data.logic, 8675);
					if (res.data.code == 1) {
						that.arrlist = res.data.data.logic
						console.log(res, 're??');
					} else {
						uni.showToast({
							title: res.data.msg,
							icon: 'none'
						});
					}
				});
			} else {
				uni.showToast({
					title:  that.$t('page_other.请输入快递单号'),
					icon: 'none'
				});
			}
		},

		tankuangguanbi() {
			this.tankuangisshows = false
		},

		tankuang() {
			this.tankuangisshows = true
		},

		jump_indexs(e) {
			console.log('sssssss');
			uni.reLaunch({
				url: '../index/index'
			});
		},

		jump_chaxun(e) {
			uni.reLaunch({
				url: '/pages/chaxun/chaxun'
			});
		},

		jump_pintuan(e) {
			// uni.reLaunch({
			//     url: '/pages/pintuan/pintuan'
			// });
			uni.navigateTo({
				url: '/pages/indexs/yunfeigusuan/yunfeigusuan'
			});
		},
		jump_personal(e) {
			uni.reLaunch({
				url: '/pages/my/my'
			});
		},

		jumpzuo() {
			uni.navigateBack();
		},
		//功能开关
		switchFun() {
			var that = this;
			var data = {
				token: uni.getStorageSync('token')
			};
			request.post(`index.php?s=/api/page/service&wxapp_id=` + uni.getStorageSync('web_id'), data).then(res => {
				if (res.data.code == 1) {
					that.switchFunlist = res.data.data.values
					that.menu_type = res.data.data.values.menu_type
					uni.setStorageSync('service_phone', res.data.data.values.service_phone);
					uni.setStorageSync('menu_type', res.data.data.values.menu_type);
					console.log(that.switchFunlist.is_wechat, 'kefu');
				} else {
					uni.showToast({
						title: res.data.msg,
						icon: 'none'
					});
				}
			});
		},

		chaxunkuaidi(e) {
			var that = this;
			var data = {
				token: uni.getStorageSync('token'),
				code: e
			};
			request.post(`index.php?s=/api/package/logicist&wxapp_id=` + uni.getStorageSync('web_id'), data).then(res => {
				if (res.data.code == 1) {
					that.arrlist = res.data.data.logic
					console.log(res, 're??');
				} else {
					uni.showToast({
						title: res.data.msg,
						icon: 'none'
					});
				}
			});
		}
	}
};
</script>
<style>
@import './chaxun.css';
</style>
